<?php

/**
 * 惩罚商家列表
 * File Name：BlacklistController.php
 * File Encoding：UTF-8
 * File New Time：2014-8-29 11:04:26
 * Author：水平凡
 * Mailbox：admin@abc3210.com
 */
class BlacklistController extends FrontBaseC {

    //永久拉黑的惩罚商家列表
    public function actionIndex() {
        //搜索
        if (IS_POST) {
            foreach ($_POST as $k => $v) {
                if ($v == '') {
                    unset($_POST[$k]);
                }
            }
            $this->redirect(self::U('index', $_POST));
            exit;
        }
        $model = BlacklistModel::model();
        //分页
        $pageId = isset($_GET['page']) ? (int) $_GET['page'] : 1;
        //分页数
        $limit = 20;
        $where = array(
            'type' => 0,
            'order' => 'id desc',
        );
        //搜索
        $nick = trim(Yii::app()->request->getParam('nick'));
        if (!empty($nick)) {
            //$info = $model->find($model->where(array('type' => 0, 'nick' => array('LIKE', "%{$nick}%",), 'order' => 'id desc' )));
            $info = $model->find($model->where(array('type' => 0, 'nick' => $nick, 'order' => 'id desc' )));
            $this->assign('nick', $nick ? $nick : array());
            $this->assign('info', $info);
        }
        $criteria = $model->where($where);
        $count = $model->count($criteria);
        //分页
        $page = self::page($count, $limit, $pageId,array(
            'tpl' => '<span class="pageindex">{pageindex}/{pagecount}</span>{first}{prev}{liststart}{list}{listend}{next}{last}',
            'listlong' => 4,
        ));
        //查询信息
        $criteria->limit = $page->listRows;
        $criteria->offset = $page->firstRow;
        $data = $model->findAll($criteria);

        $this->assign('data', $data);
        $this->assign('count', $count);
        $this->assign("Page", $page->show());
        $this->render();
    }

}
